from qiyeweixin.page_objects.page_base import PageBase
from qiyeweixin.utils_tool.logging_info import logger
from selenium.webdriver.common.by import By

'''创建部门信息页面'''
class PageCreateDepartment(PageBase):

    __IPT_DEPARTMENT = (By.NAME, "name")
    __BTN_SELETE_DEPARTMENT = (By.XPATH, "//*[text()='选择所属部门']")
    __BTN_SELETE_DEPARTMENT_1 = (By.XPATH, "//*[text()='新建部门']/../../div[2]//li[3]")
    __BTN_CONFIRM = (By.XPATH, "//*[text()='确定']")

    #添加部门信息页面：输入部门信息后保存
    def create_department(self):
        logger.info("3、新建部门页面：输入部门名称并选择所属部门后确定")
        __IPT_DEPARTMENT_NAME = f"{self.district}区"

        self.do_send_keys(__IPT_DEPARTMENT_NAME, self.__IPT_DEPARTMENT)
        self.do_click(self.__BTN_SELETE_DEPARTMENT)
        self.do_click(self.__BTN_SELETE_DEPARTMENT_1)
        self.do_click(self.__BTN_CONFIRM)

        from qiyeweixin.page_objects.page_address_book import PageAddressBook
        return PageAddressBook(self.driver)